package com.imooc.distributedemo.resume;

public class StringDemo {
    private String stringMethod(){
        String st1 = "hello";
        String st2 = "world";
        String result = st1+" , "+st2;
        return result;
    }

    private static String stringBufferAndStringBuilder(){
        StringBuilder stringBuilder = new StringBuilder(10);
        stringBuilder.append("abcdeabcd");
        int t1 = stringBuilder.capacity();
        int t2 = stringBuilder.length();
        stringBuilder.append("gggg");
        int t11 = stringBuilder.capacity(); // 为什么是22
        int t22 = stringBuilder.length();
        System.out.println(stringBuilder.toString());

        StringBuilder s1 = new StringBuilder("abc");
        int a1 = s1.capacity();
        int a2 = s1.length();

        StringBuilder s2 = new StringBuilder();
        int b1 = s2.capacity();
        int b2 = s2.length();

        StringBuilder yy = new StringBuilder("abcdeabcdeabcdeggg1");
        int yy1 = yy.capacity();
        int yy2 = yy.length();

        StringBuilder zz = new StringBuilder(20);
        zz.append("abcdeabcdeabcdeabcdeggg");
        int zz1 = zz.capacity();
        int zz2 = zz.length();
        return "stringBufferAndStringBuilder";
    }

    public static void main(String[] args) {
//        stringBufferAndStringBuilder();
        System.out.println("=======================");
        stringLength();
    }

    private static void stringLength() {
//        StringBuilder st = new StringBuilder("");
//        for (int i = 0; i < Integer.MAX_VALUE; i++) {
//            st.append(i);
//        }
//        String result = st.toString();
//        System.out.println(result.length());
    }
}
